package com.xianyun.book.domain.book;

import com.alibaba.cola.exception.BizException;

/**
 * @author ytt
 */

public enum BookFineness {
    /**全新未开封*/
    BRAND_NEW("全新未开封",0.8,0),
    /**充新*/
    QUASI_NEW("准新",0.6,1),
    /**中等*/
    MEDIUM("中等",0.4,2),
    /**良好*/
    GOOD("良好",0.3,3);
    /**说明*/
    private String finenessName;
    /**折扣率*/
    private Double discountRate;
    /**对应类型*/
    private Integer fineness;

    BookFineness(String finenessName, Double discountRate, Integer fineness) {
        this.finenessName = finenessName;
        this.discountRate = discountRate;
        this.fineness = fineness;
    }
    public static BookFineness getBookFinenessByStatus(Integer finenessType){
        for (BookFineness fineness:values()){
            if (fineness.getFineness().equals(finenessType)){
                return fineness;
            }
        }
        throw new BizException("请确认对应的折旧率类型是否正确!");
    }

    public String getFinenessName() {
        return finenessName;
    }

    public Integer getFineness() {
        return fineness;
    }

    public Double getDiscountRate() {
        return discountRate;
    }
}
